<?php
    include('session.inc');
    require_once('funct.inc');
    include 'color_style.php';
    include '../definitions.inc.php';
    include LANGUAGE;
    if(!GetAdminID($ID)){echo LOGIN_ERR;exit;}
    if(!Right_Check(1)){header('Location:error.php');exit;}
    
    ///----------------------------------------------------------------------
    ///-------------------Funkcia modulu LOGS--------------------------------  
	if (file_exists('modules/logs/logs.php'))
		require_once('modules/logs/logs.inc');
    ///----------------------------------------------------------------------
    ///----------------------------------------------------------------------
    
    ///----------------------------------------------------------------------
    ///-------------------Funkcia modulu valuations-------------------------- 
	if (file_exists('modules/valuations/valuations.inc'))
		require_once('modules/valuations/valuations.inc');
    ///----------------------------------------------------------------------
    ///----------------------------------------------------------------------
    
    ///----------------------------------------------------------------------
    ///----------------------------------------------------------------------  
	if (file_exists('modules/news_product/news_products.inc')){
		require_once('modules/news_product/news_products.inc');
		}
    ///----------------------------------------------------------------------
    ///----------------------------------------------------------------------
    
    ///----------------------------------------------------------------------
    ///----------------------------------------------------------------------  
	if (file_exists('modules/saleout_prod/saleout_prod.inc')){
		require_once('modules/saleout_prod/saleout_prod.inc');
		}
    ///----------------------------------------------------------------------
    ///----------------------------------------------------------------------
    
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<?php echo '<meta http-equiv="Content-Type" content="text/html; charset='._CHARSET_.';">'; ?>

<?php include 'html_style.php'; //+\"&Product_Descr=\"+Product_Descr
	print "
    
    <script type=\"text/javascript\">
		
		    function DelImage(ID,Product_Name,Product_Code,Product_Price,actionProduct,productInStack,roll_edit,roll_show,Path,Category_ID,PageNo,ActualQvantumPage,events,Product_DPH,Product_UnitType,Product_Descr){
		      var DeletingIMG;
		      if(actionProduct==1) {actionProduct=1;} else {actionProduct=0;}
		      if(productInStack==1) {productInStack=1;} else {productInStack=0;}
		      DeletingIMG= \"adm_contents.php?ID_DelImg=\"+ID+\"&Product_Name=\"+Product_Name+\"&Product_Code=\"+Product_Code+\"&Product_Price=\"+Product_Price+\"&actionProduct=\"+actionProduct+\"&productInStack=\"+productInStack+\"&roll_edit=\"+roll_edit+\"&roll_show=\"+roll_show+\"&path=\"+Path+\"&ID=\"+Category_ID+\"&PageNo=\"+PageNo+\"&ActualQvantumPage=\"+ActualQvantumPage+\"&events=\"+events+\"&Product_DPH=\"+Product_DPH+\"&Product_UnitType=\"+Product_UnitType+\"&Product_Descr=\"+Product_Descr;
		      window.open(DeletingIMG,\"contents\",\"\");
		 	}

		 	function CheckDataAndSubmit(){
		    	if(isNaN(parseFloat(document.formular.Product_Price.value)))
				{
		    		window.alert(\"".C_NESPRAVNA_HODNOTA_CENY_ZADAJTE_CISLO_SO_SPRAVNYM_ODDELOVACOM_DES_MIEST."\");
		    		return 1;
		    	}
		    	if(isNaN(parseFloat(document.formular.Product_DPH.value))){
		    		window.alert(\"".C_NESPRAVNA_HODNOTA_DPH_ZADAJTE_CISLO_SO_SPRAVNYM_ODDELOVACOM_DES_MIEST."\");
		    		return 1;
		    	}
		    	if(document.formular.Product_Name.value==\"\"){
		    		window.alert(\"".C_NAZOV_PRODUKTU_MUSI_BYT_ZADANY."\");
		    		return 1;
		    	}
		    	document.formular.submit();
		 	}
	";
	
	///////////////////////////////////////////////////////////////////////////
	// MODUL CSV_IMPORT
	if(file_exists("modules/csv_import/csv_import.php")){
		print "
		 	function OpenPage(id){
				var ComletPageName= \"modules/csv_import/csv_import.php\" + \"?ID=\" + id;
				window.open(ComletPageName,\"csv_import\",\"width=800px,height=400px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes\");
			}
		";
	}
	///////////////////////////////////////////////////////////////////////////
	print "</script>";
print "</head>";
print "<body bgcolor=\"".Background_Color."\">";



require_once('OpenDB.inc');
require_once('functs.inc');
do
{
    if (!OpenDB()){echo OPEN_DB_ERR; break;}
    $Category_ID  = $_REQUEST["ID"];
    $Search_Value = $_REQUEST["Search_Value"];
    $Path         = $_REQUEST["path"];

    if($_REQUEST["PageQuanter"]=="")
       $PageNo=$_REQUEST["PageNo"];
    else
       $PageNo=$_REQUEST["PageNo"]-1;

    if($PageNo=="" || $PageNo==-1) $PageNo=0;
 //Definicie tovarov=================================
    $ItemsOnPage = ITEMSONPAGE;
    $ShowQvantumPage = SHOWQVANTUMPAGE;
 //===================================================
    $ActualQvantumPage=$_REQUEST["ActualQvantumPage"];
    if($ActualQvantumPage=="")$ActualQvantumPage = 0;
    

    $index=0;
    $roll_edit="/";
    $roll_show="/";


    $events=$_REQUEST["events"];
    switch($events) {
           case 'add_action':   SQL_Add_Action($_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];break;

           case 'remove_action':SQL_Remove_Action($_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];break;
                                
           case 'add_new':   if (file_exists('modules/news_product/news_products.inc')){
		   						SQL_Add_new($_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];}
								break;

           case 'remove_new':if (file_exists('modules/news_product/news_products.inc')){
		   						SQL_Remove_new($_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];}
								break;
                                
           case 'add_sale':  if (file_exists('modules/saleout_prod/saleout_prod.inc')){ 
		   						SQL_Add_sale($_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];}
								break;

           case 'remove_sale':if (file_exists('modules/saleout_prod/saleout_prod.inc')){
		   						SQL_Remove_sale($_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];}
								break;
                                
           case 'stack':        SQL_is_in_stack($_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];break;

           case 'not_in_stack': SQL_not_in_stack($_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];break;

           case 'delet':        ///----------------------------------------------------------------------
                                ///-------------------Funkcia modulu LOGS--------------------------------  
                                if (file_exists("modules/logs/logs.php")){
                                        $query = mysql_query("select * from products where ID=".$_REQUEST["ID_event"]);
                                        $p_array = mysql_fetch_object($query);
                                        Log_Insert(C_TOVAR_BOL_VYMAZANY, $p_array->Product_Code, $ID);
                                }
                                ///----------------------------------------------------------------------
                                ///----------------------------------------------------------------------
                                SQL_Delet($_REQUEST["ID_event"]);
                                ///----------------------------------------------------------------------
                                ///-------------------Funkcia modulu valuations--------------------------
                                //odstranenie hodnotenia neexistujuceho produktu
                                if (file_exists("modules/valuations/valuations.php")){
                                        Valuation_T_Delete($_REQUEST["ID_event"]);
                                        Valuation_N_Delete($_REQUEST["ID_event"]);
                                }
                                ///----------------------------------------------------------------------
                                ///----------------------------------------------------------------------
                                //************************modul tables********************************
                                //**************************************************************************
                                //**************************************************************************
                                if(file_exists("modules/tables/new_tables.php"))  
                                {
                                        $sql_table= "DELETE FROM table_value WHERE ID_product=".$_REQUEST["ID_event"];
                                        mysql_query($sql_table);
                                }
                                //************************modul tables********************************
                                //**************************************************************************
                                //**************************************************************************
                                //************************top********************************
                                //**************************************************************************
                                //**************************************************************************
                                if(file_exists("modules/top_products/top_products.php"))  
                                {
                                        $sql_table= "DELETE FROM top_products WHERE ID_top=".$_REQUEST["ID_event"];
                                        mysql_query($sql_table);
                                }
                                //************************top********************************
                                //**************************************************************************
                                //**************************************************************************
                                //**************************************************************************
                                if(file_exists("modules/news_product/news_products.inc"))  
                                {
                                        $sql_table= "DELETE FROM product_news WHERE PN_ProductID=".$_REQUEST["ID_event"];
                                        mysql_query($sql_table);
                                }
                                //************************top********************************
                                //**************************************************************************
                                if(file_exists("modules/saleout_prod/saleout_prod.inc"))  
                                {
                                        $sql_table= "DELETE FROM product_sale WHERE PS_ProductID=".$_REQUEST["ID_event"];
                                        mysql_query($sql_table);
                                }
                                //************************top********************************
                                ///----------------------------------------------------------------------
                                ///-------------------Funkcia modulu random_products---------------------
                                //odstranenie hodnotenia neexistujuceho produktu
                                if (file_exists("modules/random_products/random_products.inc")){
                                        require_once("modules/random_products/random_products.inc");
                                        Delete_Product($_REQUEST["ID_event"]);
                                }
                                ///----------------------------------------------------------------------
                                ///----------------------------------------------------------------------

                                ///----------------------------------------------------------------------
                                ///-------------------Funkcia modulu shared_products---------------------
                                //odstranenie hodnotenia neexistujuceho produktu
                                if (file_exists("modules/shared_products/shared_products.inc")){
                                        mysql_query("DELETE FROM shared_products WHERE Shared_Product_ID=".$_REQUEST["ID_event"]." OR Product_ID=".$_REQUEST["ID_event"]);
                                }
                                ///----------------------------------------------------------------------
                                ///----------------------------------------------------------------------
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];break;

           case 'edit':         $roll_edit=rutine_menu_only_1($_REQUEST["roll_edit"],$_REQUEST["ID_event"]);
                                $roll_show=$_REQUEST["roll_show"];break;

           case 'edit_sql':      edit_sql($_REQUEST["ID_event"],
                                 $_REQUEST["Product_Code"],
                                 $_REQUEST["Product_Name"],
                                 $_REQUEST["Product_Price"],
                                 $_REQUEST["Product_Descr"],
                                 $_REQUEST["inStack"],
                                 $_REQUEST["action"],
                                 $_REQUEST["Product_DPH"],
                                 $_REQUEST["Product_UnitType"]);
                                $velkost_obr=MAX_IMAGE_SIZE/1000;
                                if(($_FILES['ImagePicker']['tmp_name'])!=""){
                                    if($_FILES['ImagePicker']['size']>MAX_IMAGE_SIZE){
                                        print  "<script type=\"text/javascript\">
                                            <!--
                                            window.alert(\"".C_OBRAZOK_1_JE_PRILIZ_VELKY." ".$velkost_obr." kB.\");
                                            //-->
                                         </script>";
                                    }
                                    else{
                                         File_Upload($_FILES['ImagePicker']['tmp_name'],$_REQUEST["ID_event"]);
                                    }
                                }
                                if(($_FILES['ImagePicker2']['tmp_name'])!=""){
                                    if($_FILES['ImagePicker2']['size']>MAX_IMAGE_SIZE){
                                        print  "<script type=\"text/javascript\">
                                            <!--
                                            window.alert(\"".C_OBRAZOK_2_JE_PRILIZ_VELKY." ".$velkost_obr." kB.\");
                                            //-->
                                         </script>";
                                    }
                                    else{
                                         File_Upload($_FILES['ImagePicker2']['tmp_name'],$_REQUEST["ID_event"].'d2');
                                    }
                                }
                                if(($_FILES['ImagePicker3']['tmp_name'])!=""){
                                    if($_FILES['ImagePicker3']['size']>MAX_IMAGE_SIZE){
                                        print  "<script type=\"text/javascript\">
                                            <!--
                                            window.alert(\"".C_OBRAZOK_3_JE_PRILIZ_VELKY." ".$velkost_obr." kB.\");
                                            //-->
                                         </script>";
                                    }
                                    else{
                                         File_Upload($_FILES['ImagePicker3']['tmp_name'],$_REQUEST["ID_event"].'d3');
                                    }
                                }
                                //************************modul tables********************************
                                //**************************************************************************
                                //**************************************************************************
                                if(file_exists("modules/tables/insert_edit_sql.inc"))  
                                {
                                  include('modules/tables/insert_edit_sql.inc');
                                }
                                //**************************************************************************
                                //**************************************************************************
                                //************************************************************************** 
                                $roll_edit=rutine_menu($_REQUEST["roll_edit"],$_REQUEST["ID_event"]);
                                $roll_show=rutine_menu($_REQUEST["roll_show"],$_REQUEST["ID_event"]);
                                break;

           case 'show':         $roll_show=rutine_menu($_REQUEST["roll_show"],$_REQUEST["ID_event"]);
                                $roll_edit=$_REQUEST["roll_edit"];                                
                                break;
									
           case 'DelImg':       $save_actionProduct=$_REQUEST["actionProduct"];
                                $save_productInStack=$_REQUEST["productInStack"];
                                $save_Product_Code=$_REQUEST["Product_Code"];
                                $save_Product_Name=$_REQUEST["Product_Name"];
                                $save_Product_Price=$_REQUEST["Product_Price"];
                                $save_Product_Descr=$_REQUEST["Product_Descr"];
                                $save_Product_DPH=$_REQUEST["Product_DPH"];
                                $save_Product_UnitType=$_REQUEST["Product_UnitType"];
                                $roll_show=$_REQUEST["roll_show"];
                                $roll_edit=$_REQUEST["roll_edit"];
                                $ID_DelImg=$_REQUEST["ID_DelImg"];
                                unlink("../data/images/".$ID_DelImg.".jpg");
                                unlink("../data/images/".$ID_DelImg."mini.jpg");
                                break;

           default:             break;
    }
    if(trim($Category_ID)=="" and trim($Search_Value)==""){
        mysql_close();
        break;        
    }
    if(trim($Category_ID)!="" and $Category_ID>0){
        print "<form  action=\"adm_new_product.php\" target=\"contents\" method=\"post\">";
        print "<table  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"".TR_BACKGOUND_COLOR_2."\" align=\"center\" width=\"500px\"><tr>";
        print "<td align=\"center\">";
        print "<input type=\"hidden\" value=\"".$Category_ID."\" NAME=\"ID\" />";
        print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
        print "<input type=\"submit\" value=\"".C_NOVY_TOVAR." ".$Path."\" style=\"width 300px; background-color: ".BUTTON_ON_OUT.";\"
                    onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
                    onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
        print "</td>";

        if (file_exists("modules/csv_import/csv_import.php")){
            print "<td>";
            print "<input type=\"button\" value=\"Import dat\"
                style=\"border:1px solid black; background-color: transparent; text-align:left;\"
                onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\"
                onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\"
                onClick=\"OpenPage(".$_REQUEST['ID'].");\" />";
            print "</td>";
        }

        print "</tr></table>";
        print "</form>";
    }

    if(trim($Category_ID)=="-1") print "<center>".M_AKCIE."</center>";
    if(trim($Category_ID)=="-2") print "<center>".M_NOVINKY."</center>";
    if(trim($Category_ID)=="-3") print "<center>".M_VYPREDAJ."</center>";
    
//************************modul tables********************************
//**************************************************************************
//**************************************************************************
if(file_exists("modules/tables/insert_switch.inc"))  
{
	include('modules/tables/insert_switch.inc');
}
//**************************************************************************
//**************************************************************************
//**************************************************************************   
        print"<center><b>".$Path;
//************************modul discount********************************
//**************************************************************************
//**************************************************************************        
if (file_exists("modules/discount/discount.inc") and is_numeric($Category_ID) and $Category_ID>0)
        {
            require_once ('modules/discount/discount.inc');
            $DiscPerc=DiscountPercent($Category_ID);
            if($DiscPerc)
            print "<font color=\"#FF0000\" > pridelena $DiscPerc % zlava</font>";
        }
//************************modul discount********************************
//**************************************************************************
//**************************************************************************
	print"</b></center>";
        print "<hr width=\"98%\" align=\"left\" style=\"border-top:1px solid black; margin-bottom=0; margin-top=0;
           position:relative;left:0px; top:10px;\" />";
    //PrintLine();
    // print"<br />";
    //**************************************************************************
    //
    //Vytvorenie menu pre vyber zobrazovanej stranky (rozdelenie zobrazovane hotovaru) - ulozene hore
    //
    //**************************************************************************
    
    if(trim($Search_Value)!=''){
      if(file_exists("modules/tables/insert_11.inc")){
        $sql_psel= "
            SELECT COUNT(*) FROM products,table_value
            WHERE (		
              (products.Product_Name LIKE '%".$Search_Value."%') OR
              (products.Product_Code='".$Search_Value."') OR
              (products.Product_Descr LIKE '%".$Search_Value."%') OR
              (
                (table_value.descr_value LIKE '%".$Search_Value."%') AND
                (products.ID=table_value.ID_product)
              )
            ) GROUP BY (products.ID)
        ";
      }
      else{
        $sql_psel= "
            SELECT COUNT(*) FROM products
            WHERE(
                (Product_Name LIKE '%".$Search_Value."%') OR
                (Product_Code='".$Search_Value."') OR
                (Product_Descr LIKE '%".$Search_Value."%')
            )
            GROUP BY (ID)
        ";
      }
    }    
    else{
      if(trim($Category_ID)!='' and $Category_ID>0) $sql_psel= "SELECT COUNT(*) FROM products WHERE SC_ID=".$Category_ID;
      if(trim($Category_ID)=='-1') $sql_psel= "SELECT COUNT(*) FROM products, product_actions WHERE products.ID=product_actions.PA_ProductID";
      if(trim($Category_ID)=='-2') $sql_psel= "SELECT COUNT(*) FROM products, product_news WHERE products.ID=product_news.PN_ProductID";
      if(trim($Category_ID)=='-3') $sql_psel= "SELECT COUNT(*) FROM products, product_sale  WHERE products.ID=product_sale.PS_ProductID";
    }

    $sql_array_Prodct = mysql_fetch_row(mysql_query($sql_psel));


    if($sql_array_Prodct[0]/$ItemsOnPage==($PageNo)) $PageNo--;
    if($sql_array_Prodct[0]/$ItemsOnPage<=$ActualQvantumPage) $ActualQvantumPage=$ActualQvantumPage-$ShowQvantumPage;

   do{
      if (($sql_array_Prodct[0]/$ItemsOnPage)<=1) break;
      print"<center><table style=\"position:relative;  top:5px;\"><tr>";

// Podmienka prvej >>>> --------------------------------------------------------------------
      if(($sql_array_Prodct[0]/$ItemsOnPage>$ShowQvantumPage) and ($ActualQvantumPage-$ShowQvantumPage>=0)){
             print "<td>";
             print "<form  action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
             if($sql_array_Prodct[0]>$ShowQvantumPage)
               print "
                  <input type=\"submit\" value=\"<<<\"  style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
                    onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                    onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" 
                  />
               ";
               $xxx=$ActualQvantumPage-$ShowQvantumPage;
               $Pagexxx=$xxx;
               print "<input type=\"hidden\" value=\"".$Pagexxx."\" name=\"PageNo\" />";
               print "<input type=\"hidden\" value=\"".$xxx."\" name=\"ActualQvantumPage\" />";
               print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
               print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
               print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
             print "</form>";
             print "</td>";
             }
 //--------------------------------------------------------------------------------------

 //podmienka zvysnych stranok------------------------------------------------------------
          if(($ActualQvantumPage/$ShowQvantumPage)==floor(($sql_array_Prodct[0]/$ItemsOnPage)/$ShowQvantumPage))
              { if($sql_array_Prodct[0]%$ItemsOnPage==0)
                    $ShowActualQvantumPage=((($sql_array_Prodct[0]/$ItemsOnPage)%$ShowQvantumPage));
                else
                    $ShowActualQvantumPage=((($sql_array_Prodct[0]/$ItemsOnPage)%$ShowQvantumPage)+1);
              }
          else
              {$ShowActualQvantumPage=$ShowQvantumPage;}
 //---------------------------------------------------------------------------------------
      for($i=$ActualQvantumPage;$i<$ActualQvantumPage+$ShowActualQvantumPage;$i++)
    {
      print "<form  action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
          print "<td>";
          $Xi=$i+1;
          if($PageNo==$i)
            print "<input type=\"submit\" value=\"".$Xi."\" name=\"PageNo\"  style=\"width :50px; background-color: ".BUTTON_ON_OVER.";\" />";
          else
            print "<input type=\"submit\" value=\"".$Xi."\" name=\"PageNo\" style=\"width :25px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
          print "<input type=\"hidden\" value=\"1\" name=\"PageQuanter\" />";
          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
          print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
          print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
          print "</form>";
          print "</td>";
    }

 //podmienka doprednej >>>> -----------------------------------------------------------
    if(($sql_array_Prodct[0]/$ItemsOnPage) > ($ActualQvantumPage+$ShowQvantumPage)){
      print "<td>";
      print "<form  action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
      print "<input type=\"submit\" value=\">>>\"  style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
              onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
              onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
      $xxx=$ActualQvantumPage+$ShowQvantumPage;
      $Pagexxx=$xxx;
      print "<input type=\"hidden\" value=\"".$Pagexxx."\" name=\"PageNo\" />";
      print "<input type=\"hidden\" value=\"".$xxx."\" name=\"ActualQvantumPage\" />";
      print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
      print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
      print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
    print "</form>";
    print "</td>";
     }
 //--------------------------------------------------------------------------------------
    print "</tr></table></center>";
    PrintLine();


    }while(false);

    //print "<br />";
	print "<font color=\"#FF0000\" ><small><b>".C_AKCIA."</b></small></font color><font color=\"#0000FF\" ><small><b>".C_NOVINKA."</b></small></font color><font color=\"#00FF00\" ><small><b>".C_VYPREDAJ."</b></small></font color>";
    //**************************************************************************
    //
    //Naplneneie obsahu stranky datami z databazy
    //
    //**************************************************************************
    if(trim($Category_ID)=='' and trim($Search_Value)==''){mysql_close(); break;}
        $From   = $PageNo*$ItemsOnPage;
        if($From<0) $From=0;
        
        
    if(trim($Search_Value)!=''){
      if(file_exists("modules/tables/insert_11.inc")){
        $sql_psel= "
          SELECT    
            products.ID,
            products.Product_Name,
            products.Product_Descr,
            products.Product_Price,
            products.Product_Availability,
            products.Product_Code,
            products.Product_UnitType,
            products.Product_DPH,
            table_value.ID_product,
            table_value.descr_value
          FROM products,table_value
          WHERE (
            (products.Product_Name LIKE '%".$Search_Value."%') OR
	    (products.Product_Code='".$Search_Value."') OR
            (products.Product_Descr LIKE '%".$Search_Value."%') OR
            (
              (table_value.descr_value LIKE '%".$Search_Value."%') AND (products.ID=table_value.ID_product)
            )
          ) 
          GROUP BY (products.ID)
          LIMIT ".$From.",".$ItemsOnPage;
      }
      else{
        $sql_psel= "
          SELECT * 
          FROM products 
          WHERE(
            (Product_Name LIKE '%".$Search_Value."%') OR
            (Product_Code='".$Search_Value."') OR
            (Product_Descr LIKE '%".$Search_Value."%')
          )
          GROUP BY (ID)
          LIMIT ".$From.",".$ItemsOnPage;
      }
    }    
    else{
      if(trim($Category_ID)!='' and $Category_ID>0) $sql_psel=  "SELECT * FROM products WHERE SC_ID=".$Category_ID." ORDER BY Product_Name LIMIT ".$From.",".$ItemsOnPage;
      if(trim($Category_ID)=='-1') $sql_psel= "SELECT products.* FROM products, product_actions WHERE products.ID=product_actions.PA_ProductID ORDER BY Product_Name LIMIT ".$From.",".$ItemsOnPage;
      if(trim($Category_ID)=='-2') $sql_psel= "SELECT products.* FROM products, product_news WHERE products.ID=product_news.PN_ProductID ORDER BY Product_Name LIMIT ".$From.",".$ItemsOnPage;
      if(trim($Category_ID)=='-3') $sql_psel= "SELECT products.* FROM products, product_sale WHERE products.ID=product_sale.PS_ProductID ORDER BY Product_Name LIMIT ".$From.",".$ItemsOnPage;
    }
        
        
        //print $sql_psel;
        $Product_source = mysql_query($sql_psel);
        $counter=0;
         while($sql_array_Prodct = mysql_fetch_object($Product_source))
         {
                    $actual_roll_edit=is_roll($roll_edit,$sql_array_Prodct->ID);
                    $actual_roll_show=is_roll($roll_show,$sql_array_Prodct->ID);

                  if($sql_array_Prodct->ID==$ID_DelImg){
                    $actionProduct=$save_actionProduct;
                    $productInStack=$save_productInStack;
                    $Product_Name=$save_Product_Name;
                    $Product_Descr=$sql_array_Prodct->Product_Descr;
                    $Product_Descr=$save_Product_Descr;
                    $Product_Code=$save_Product_Code;
                    $Product_Price=$save_Product_Price;
                    $Product_DPH=$save_Product_DPH;
                    $Product_UnitType=$save_Product_UnitType;
                  }else{
                    $actionProduct=Is_Action($sql_array_Prodct->ID);
                    $productInStack=Is_in_stack($sql_array_Prodct->ID);
                    $Product_Name=$sql_array_Prodct->Product_Name;
                    $Product_Descr=$sql_array_Prodct->Product_Descr;
                    $Product_Code=$sql_array_Prodct->Product_Code;
                    $Product_Price=$sql_array_Prodct->Product_Price;
                    $Product_DPH=$sql_array_Prodct->Product_DPH;
                    $Product_UnitType=$sql_array_Prodct->Product_UnitType;
              }

        if(!($actual_roll_edit ||
            $actual_roll_show))
        {
        if(($counter%2))
            print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"98%\" bgcolor=\"".TR_BACKGOUND_COLOR_2."\">";
        else
            print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"98%\" bgcolor=\"".TR_BACKGOUND_COLOR_1."\">";

                            //zobrazenie nazvu tovaru
                    print "<tr><td>";
                        if(($counter%2))
                            print "<table  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" bgcolor=\"".TR_BACKGOUND_COLOR_2."\"><tr>";
                        else
                            print "<table  border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" bgcolor=\"".TR_BACKGOUND_COLOR_1."\"><tr>";

                    print "<td align=\"left\" width=\"120px\">";
                      print("<b><font color=\"black\"><small>[".$sql_array_Prodct->Product_Code."]</small></font color></b>");
                    print "</td>";
                    print "<td align=\"left\" >";
                      print("<b><font color=\"".TEXT_COLOR."\"><small>".$sql_array_Prodct->Product_Name."</small></font color></b>");
                    print "</td>";
                    print "<td align=\"right\" width=\"15px\">";
                             if($actionProduct)
                                print   "<font color=\"#FF0000\" ><small><b>".C_AKCIA_BTN."</b></small></font color>";
                    print "</td>";
                    
                        ///----------------------------------------------------------------------
                        ///----------------------------------------------------------------------  
                            if (file_exists('modules/news_product/news_products.inc')){
                              print "<td align=\"right\" width=\"15px\">";
                              if(Is_new($sql_array_Prodct->ID))
                                print   "<font color=\"#0000FF\" ><small><b>".C_NOVINKA_BTN."</b></small></font color>";
                                print "</td>";
                            }
                        //---------------------------------------------------------------------
                        //---------------------------------------------------------------------                    
					
                    
                    	///----------------------------------------------------------------------
                        ///----------------------------------------------------------------------
                        if (file_exists('modules/saleout_prod/saleout_prod.inc')){
                          print "<td align=\"right\" width=\"15px\">";
                             if(Is_sale($sql_array_Prodct->ID))
                                print   "<font color=\"#00FF00\" ><small><b>".C_VYPREDAJ_BTN."</b></small></font color>";
                    		print "</td>";
                    	}
                    	//----------------------------------------------------------------------
                    	//----------------------------------------------------------------------
                            print "<td align=\"right\" width=\"65px\">";
                             switch($sql_array_Prodct->Product_Availability){
                                 case 0:print   "<font color=\"black\" ><small>[".C_NIEJE_NASKLADE."]</small></font color>";break;
                                 case 1:print   "<font color=\"black\" ><small>[".C_NASKLADE."]</small></font color>";break; }
                    print "</td>";
                    print "<td align=\"right\" width=\"90px\">";
                      print("<b><font color=\"".TEXT_COLOR."\"><small>".FormatItAsCurrency($sql_array_Prodct->Product_Price)." ".C_MENA."</small></font color></b>");
                    print "</td>";
                    print "</tr></table></td>";

                  print "<td align=\"right\" width=\"18px\">";
                      if(!$actionProduct){
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                          print "<input type=\"hidden\" name=\"events\" value=\"add_action\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                          print "<input type=\"submit\" value=\"".C_AKCIA_BTN."\" style=\"width :15px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                      }
                      else{
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                          print "<input type=\"hidden\" name=\"events\" value=\"remove_action\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                          print "<input type=\"submit\" value=\"".C_AKCIA_BTN."\" style=\"width :15px; background-color: #FF0000;\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='#FF0000'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                      }
                          
                   
                ///----------------------------------------------------------------------
                ///----------------------------------------------------------------------  
                    if (file_exists('modules/news_product/news_products.inc')){
                      print "<td align=\"right\" width=\"18px\">";
                      if(!Is_new($sql_array_Prodct->ID)){
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                          print "<input type=\"hidden\" name=\"events\" value=\"add_new\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                          print "<input type=\"submit\" value=\"".C_NOVINKA_BTN."\" style=\"width :15px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                          }
                      else{
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                          print "<input type=\"hidden\" name=\"events\" value=\"remove_new\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                          print "<input type=\"submit\" value=\"".C_NOVINKA_BTN."\" style=\"width :15px; background-color: #0000FF;\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='#0000FF'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                          }
                   }
		//-----------------------------------------------------------------------       
                ///----------------------------------------------------------------------
                ///----------------------------------------------------------------------  
                    if (file_exists('modules/saleout_prod/saleout_prod.inc')){
                        print "<td align=\"right\" width=\"18px\">";
                      if(!Is_sale($sql_array_Prodct->ID)){
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                          print "<input type=\"hidden\" name=\"events\" value=\"add_sale\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                          print "<input type=\"submit\" value=\"".C_VYPREDAJ_BTN."\" style=\"width :15px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                          }
                      else{
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                          print "<input type=\"hidden\" name=\"events\" value=\"remove_sale\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                          print "<input type=\"submit\" value=\"".C_VYPREDAJ_BTN."\" style=\"width :15px; background-color: #00FF00;\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='#00FF00'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                          }
                  }        
                  //----------------------------------------------------------------------------
                  //---------------------------------------------------------------------------
                  print "<td align=\"right\" width=\"83px\">";
                      if(!$productInStack){
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\" />";
                          print "<input type=\"hidden\" name=\"events\" value=\"stack\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                          print "<input type=\"submit\" value=\"".C_NASKLADE."\" style=\"width :80px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                          }
                      else{
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\">";
                          print "<input type=\"hidden\" name=\"events\" value=\"not_in_stack\">";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\">";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\">";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\">";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\">";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\">";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\">";
                          print "<input type=submit value='".C_NIEJE_NASKLADE."' style=\"width :80px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\">";print "</form>";print "</td>";
                          }

                  print "<td align=\"right\" width=\"83px\">";
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\"/>";
                          print "<input type=\"hidden\" name=\"events\" value=\"show\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\">";
                          print "<input type=\"submit\" value=\"".C_PODROBNOSTI."\" style=\"width :80px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                  print "<td align=\"right\" width=\"53px\">";
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" NAME=\"ActualQvantumPage\" />";
                          print "<input type=\"hidden\" name=\"events\" value=\"edit\" />";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\" />";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\" />";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\" />";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\" />";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\" />";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\" />";
                          print "<input type=\"submit\" value=\"".C_EDIT."\" style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>";
                  print "<td align=\"right\" width=\"53px\">";
                          print "<form action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
                          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" name=\"ActualQvantumPage\">";
                          print "<input type=\"hidden\" name=\"events\" value=\"delet\">";
                          print "<input type=\"hidden\" name=\"roll_edit\" value=\"".$roll_edit."\">";
                          print "<input type=\"hidden\" name=\"roll_show\" value=\"".$roll_show."\">";
                          print "<input type=\"hidden\" name=\"ID_event\" value=\"".$sql_array_Prodct->ID."\">";
                          print "<input type=\"hidden\" name=\"path\" value=\"".$Path."\">";
                          print "<input type=\"hidden\" name=\"ID\" value=\"".$Category_ID."\">";
                          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
                          print "<input type=\"hidden\" name=\"PageNo\" value=\"".$PageNo."\">";
                          print "<input type=\"submit\" value=\"".C_VYMAZ."\" style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";print "</form>";print "</td>
              </tr>";
       }
       else{
       //formular pre edit alebo show
       if($actual_roll_edit){ //otvorenie formulara na edit produktov

        if ($actionProduct) $ChBox[0]="checked"; else $ChBox[0]="";
        if ($productInStack)$ChBox[1]="checked"; else $ChBox[1]="";

        if($counter%2) $bgcolor = TR_BACKGOUND_COLOR_2; else $bgcolor = TR_BACKGOUND_COLOR_1;
    
        //shared products button
        if(file_exists("modules/shared_products/shared_products.inc")){
            require_once("modules/shared_products/shared_products.inc");
            $shared_products = '
                <input type="button" alt="'.SP_SUVISIACE_PRODUKTY.'" value="'.SP_SUVISIACE_PRODUKTY.' ['.Selected_Products_Total_Count($sql_array_Prodct->ID).']"
                    style="border:1px solid black; width :160px; background-color: '.BUTTON_ON_OUT.';"
                    onmouseover="this.style.backgroundColor=\''.BUTTON_ON_OVER.'\'; this.style.fontWeight=\'bold\';"
                    onmouseout="this.style.backgroundColor=\''.BUTTON_ON_OUT.'\'; this.style.fontWeight=\'normal\';"
                    onClick="javascript:window.open(\'modules/shared_products/adm_main_frame.php?ProductID='.$sql_array_Prodct->ID.'\',\'shared_products\',\'width=1000px,height=600px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes\');"
                />
            ';
         }
         //default hidden elements
         $hidden_elements ='
            <input type="hidden" name="events" id="events" />
            <input type="hidden" name="ActualQvantumPage" value="'.$ActualQvantumPage.'" />
            <input type="hidden" name="roll_edit" value="'.$roll_edit.'" />
            <input type="hidden" name="roll_show" value="'.$roll_show.'" />
            <input type="hidden" name="ID_event" value="'.$sql_array_Prodct->ID.'" />
            <input type="hidden" name="path" value="'.$Path.'" />
            <input type="hidden" name="ID" value="'.$Category_ID.'" />
            <input type="hidden" value="'.$Search_Value.'" name="Search_Value" />
            <input type="hidden" name="PageNo" value="'.$PageNo.'" />
         ';
         //save button
         $save_button = '
            <input type="button" value="'.C_ULOZ.'"
                style="width :160px; background-color: '.BUTTON_ON_OUT.';"
                onmouseover="this.style.backgroundColor=\''.BUTTON_ON_OVER.'\'; this.style.fontWeight=\'bold\';"
                onmouseout="this.style.backgroundColor=\''.BUTTON_ON_OUT.'\'; this.style.fontWeight=\'normal\';"
                onClick="
                    document.formular.events.value = \'edit_sql\';
                    CheckDataAndSubmit();
                "
            />
        ';
        //cancel button
        $cancel_button = '
            <input type="submit" value="'.C_NASPAT.'"
                style="width :160px; background-color: '.BUTTON_ON_OUT.';"
                onmouseover="this.style.backgroundColor=\''.BUTTON_ON_OVER.'\'; this.style.fontWeight=\'bold\';"
                onmouseout="this.style.backgroundColor=\''.BUTTON_ON_OUT.'\'; this.style.fontWeight=\'normal\';"
                onClick="document.formular.events.value = \'edit_sql\';"
            />
        ';
        //delete button
        $delete_button = '
            <input type="submit" value="'.C_VYMAZ.'"
                style="width :160px; background-color: '.BUTTON_ON_OUT.';"
                onmouseover="this.style.backgroundColor=\''.BUTTON_ON_OVER.'\'; this.style.fontWeight=\'bold\';"
                onmouseout="this.style.backgroundColor=\''.BUTTON_ON_OUT.'\'; this.style.fontWeight=\'normal\';"
                onClick="document.formular.events.value = \'delet\';"
            />
        ';
        //update form
        $update_form = '
            <table  border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="'.$bgcolor.'">
                <tr>
                    <td>
                        <b>'.C_NAZOV.':</b> <input type="text" name="Product_Name" id="Product_Name" size="35" maxlength="50" value="'.$Product_Name.'" />
                        <b>'.C_KOD.':</b> <input type="text" name="Product_Code" id="Product_Code" size="20" maxlength="20" value="'.$Product_Code.'" />
                    </td>
                </tr>
                <tr>
                    <td style="padding-top:10px;">
                        <b>'.C_POPIS.':</b><br>
                        <textarea name="Product_Descr" rows="8" wrap="on" style="width:390px;">'.$Product_Descr.'</textarea>
                    </td>
                </tr>
                <tr>
                    <td style="padding-top:10px;">
                        <b>'.C_DPH.':</b> <input type="text" name="Product_DPH" id="Product_DPH" maxlength="2" size="5" value="'.$Product_DPH.'" />
                        %
                        <b>'.C_CENA.':</b> <input type="text" name="Product_Price" id="Product_Price" size="12" value="'.FormatItAsCurrencyTEXTEDIT($Product_Price).'" />
                        '.C_MENA.' / 
                        <input type="text" name="Product_UnitType" id="Product_UnitType" maxlength="5" size="5" value="'.$Product_UnitType.'" />
                    </td>
                </tr>
                <tr>
                    <td style="padding-top:10px;">
                        <input type="checkbox" value="1/" name="action" '.$ChBox[0].' />
                        <font color="red" ><small><b>'.C_AKCIA_POPIS.'</b></small></font>
                        <input type="checkbox" value="2/" name="inStack" '.$ChBox[1].' />
                        <font color="black" ><small>'.C_TOVAR_NA_SKLADE.'</small></font>
                    </td>
                </tr>

            </table>
        ';
        //images list        
        $image_name  ="../data/images/".$sql_array_Prodct->ID."mini.jpg";
        $image_name2 ="../data/images/".$sql_array_Prodct->ID."d2mini.jpg";
        $image_name3 ="../data/images/".$sql_array_Prodct->ID."d3mini.jpg";
        $images_list = '
            <tr>
                <td>
                    <center><b>'.C_OBRAZKY.':</b></center>
                </td>
            </tr>
        ';
        if(file_exists($image_name)) $images_list .= "
            <tr>
                <td width=\"90px\">
                    <img
                        style=\"cursor:hand;\"
                        src=\"".$image_name."?n=".rand(0, 2000)."\" align=\"left\" vspace=\"0px\" style=\"margin:5px;width : 70px;\"
                        onClick=\"javascript:window.open('image_show.php?image_name_big=../data/images/".$sql_array_Prodct->ID.".jpg','Image','width=680px,height=500px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                    />
                    <br /><br />
                    <a href=\"javascript:\"
                        style=\"width :90px; background-color: ".BUTTON_ON_OUT.";\"
                        onClick=\"DelImage('".$sql_array_Prodct->ID."',document.formular.Product_Name.value,document.formular.Product_Code.value,document.formular.Product_Price.value,document.formular.action.checked,document.formular.inStack.checked,'".$roll_edit."','".$roll_show."','".$Path."','".$Category_ID."','".$PageNo."','".$ActualQvantumPage."','DelImg',document.formular.Product_DPH.value,document.formular.Product_UnitType.value,document.formular.Product_Descr.value);\"
                    >".C_VYMAZ_OBRAZOK."</a>
                </td>
            </tr>";
        else $images_list .= "
            <tr>
                <td>
                    <input type=\"file\" accept=\".jpg\" size=\"14\" name=\"ImagePicker\" title=\"".C_VYBER_OBRAZKU."\" />
                </td>
            </tr>";

        if(file_exists($image_name2)) $images_list .= "
            <tr>
                <td width=\"90px\">
                    <img
                        style=\"cursor:hand;\"
                        src=\"".$image_name2."?n=".rand(0, 2000)."\" align=\"left\" vspace=\"0px\" style=\"margin:5px;width : 70px;\"
                        onClick=\"javascript:window.open('image_show.php?image_name_big=../data/images/".$sql_array_Prodct->ID."d2.jpg','Image','width=680px,height=500px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                    />
                    <br /><br />
                    <a href=\"javascript:\"
                        style=\"width :90px; background-color: ".BUTTON_ON_OUT.";\"
                        onClick=\"DelImage('".$sql_array_Prodct->ID."d2',document.formular.Product_Name.value,document.formular.Product_Code.value,document.formular.Product_Price.value,document.formular.action.checked,document.formular.inStack.checked,'".$roll_edit."','".$roll_show."','".$Path."','".$Category_ID."','".$PageNo."','".$ActualQvantumPage."','DelImg',document.formular.Product_DPH.value,document.formular.Product_UnitType.value,document.formular.Product_Descr.value);\"
                    >".C_VYMAZ_OBRAZOK."</a>
                </td>
            </tr>";
        else $images_list .= "
            <tr>
                <td>
                    <input type=\"file\" accept=\".jpg\" size=\"14\" name=\"ImagePicker2\" title=\"".C_VYBER_OBRAZKU."\" />
                </td>
            </tr>";

        if(file_exists($image_name3)) $images_list .= "
            <tr>
                <td width=\"90px\">
                    <img
                        style=\"cursor:hand;\"
                        src=\"".$image_name3."?n=".rand(0, 2000)."\" align=\"left\" vspace=\"0px\" style=\"margin:5px;width : 70px;\"
                        onClick=\"javascript:window.open('image_show.php?image_name_big=../data/images/".$sql_array_Prodct->ID."d3.jpg','Image','width=680px,height=500px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                    />
                    <br /><br />
                    <a href=\"javascript:\"
                        style=\"width :90px; background-color: ".BUTTON_ON_OUT.";\"
                        onClick=\"DelImage('".$sql_array_Prodct->ID."d3',document.formular.Product_Name.value,document.formular.Product_Code.value,document.formular.Product_Price.value,document.formular.action.checked,document.formular.inStack.checked,'".$roll_edit."','".$roll_show."','".$Path."','".$Category_ID."','".$PageNo."','".$ActualQvantumPage."','DelImg',document.formular.Product_DPH.value,document.formular.Product_UnitType.value,document.formular.Product_Descr.value);\"
                    >".C_VYMAZ_OBRAZOK."</a>
                </td>
            </tr>";
        else $images_list .= "
            <tr>
                <td>
                    <input type=\"file\" accept=\".jpg\" size=\"14\" name=\"ImagePicker3\" title=\"".C_VYBER_OBRAZKU."\" />
                </td>
            </tr>";

        //table
        print '
            <form name="formular" action="adm_contents.php" target="contents" method="post"  enctype="multipart/form-data">
            '.$hidden_elements.'
            <table  border="0" cellpadding="3" cellspacing="3" width="780px" bgcolor="'.$bgcolor.'">
                <tr>
                    <td style="width:190px; text-align:left; vertical-align:top; border-right: 1px dotted black;"> <!-- Images -->
                        <table  border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="'.$bgcolor.'">
                            '.$images_list.'
                        </table>
                    </td>
                    <td style="width:410px; text-align:left; vertical-align:top; border-right: 1px dotted black;"> <!-- Products info -->
                        '.$update_form.'
                    </td>
                    <td style="width:160px; text-align:right; vertical-align:top;"> <!-- Controls -->
                        <table  border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="'.$bgcolor.'">
                            <tr>
                                <td>
                                    '.$shared_products.'
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top:10px;">
                                    '.$save_button.'
                            </tr>
                            <tr>
                                <td>
                                    '.$cancel_button.'
                                </td>
                            </tr>
                            <tr>
                                <td style="padding-top:10px;">
                                    '.$delete_button.'
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            </form>
        ';
    }
    else{
        if($actual_roll_show){ //zobrazenie detailu produktu
            if ($actionProduct) $ChBox[0]="checked"; else $ChBox[0]="";
            if ($productInStack)$ChBox[1]="checked"; else $ChBox[1]="";

            //otvorenie formulara na show podrobnosti
            if($counter%2) $bgcolor = TR_BACKGOUND_COLOR_2; else $bgcolor = TR_BACKGOUND_COLOR_1;

            //default hidden elements
            $hidden_elements ='
                
            ';
            //cancel button
            $cancel_button = '
                <form action="adm_contents.php" target="contents" method="post">
                    <input type="hidden" name="events" id="events" value="show" />
                    <input type="hidden" name="ActualQvantumPage" value="'.$ActualQvantumPage.'" />
                    <input type="hidden" name="roll_edit" value="'.$roll_edit.'" />
                    <input type="hidden" name="roll_show" value="'.$roll_show.'" />
                    <input type="hidden" name="ID_event" value="'.$sql_array_Prodct->ID.'" />
                    <input type="hidden" name="path" value="'.$Path.'" />
                    <input type="hidden" name="ID" value="'.$Category_ID.'" />
                    <input type="hidden" value="'.$Search_Value.'" name="Search_Value" />
                    <input type="hidden" name="PageNo" value="'.$PageNo.'" />
                    <input type="submit" value="'.C_ZAVRIET.'"
                        style="width :160px; background-color: '.BUTTON_ON_OUT.';"
                        onmouseover="this.style.backgroundColor=\''.BUTTON_ON_OVER.'\'; this.style.fontWeight=\'bold\';"
                        onmouseout="this.style.backgroundColor=\''.BUTTON_ON_OUT.'\'; this.style.fontWeight=\'normal\';"
                    />
                </form>
            ';
            //edit button
            $edit_button = '
                <form action="adm_contents.php" target="contents" method="post">
                    <input type="hidden" name="ActualQvantumPage" value="'.$ActualQvantumPage.'" />
                    <input type="hidden" name="events" value="edit" />
                    <input type="hidden" name="roll_edit" value="'.$roll_edit.'" />
                    <input type="hidden" name="roll_show" value="'.$roll_show.'" />
                    <input type="hidden" name="ID_event" value="'.$sql_array_Prodct->ID.'" />
                    <input type="hidden" name="path" value="'.$Path.'" />
                    <input type="hidden" name="ID" value="'.$Category_ID.'" />
                    <input type="hidden" value="'.$Search_Value.'" name="Search_Value" />
                    <input type="hidden" name="PageNo" value="'.$PageNo.'" />
                    <input type="submit" value="'.C_EDIT.'" style="width :160px; background-color: '.BUTTON_ON_OUT.';"
                        onmouseover="this.style.backgroundColor=\''.BUTTON_ON_OVER.'\'; this.style.fontWeight=\'bold\';"
                        onmouseout="this.style.backgroundColor=\''.BUTTON_ON_OUT.'\'; this.style.fontWeight=\'normal\';" 
                    />
                </form>
            ';
            //delete button
            $delete_button = '
                <form action="adm_contents.php" target="contents" method="post">
                    <input type="hidden" name="ActualQvantumPage" value="'.$ActualQvantumPage.'" />
                    <input type="hidden" name="events" value="delet" />
                    <input type="hidden" name="roll_edit" value="'.$roll_edit.'" />
                    <input type="hidden" name="roll_show" value="'.$roll_show.'" />
                    <input type="hidden" name="ID_event" value="'.$sql_array_Prodct->ID.'" />
                    <input type="hidden" name="path" value="'.$Path.'" />
                    <input type="hidden" name="ID" value="'.$Category_ID.'" />
                    <input type="hidden" value="'.$Search_Value.'" name="Search_Value" />
                    <input type="hidden" name="PageNo" value="'.$PageNo.'" />
                    <input type="submit" value="'.C_VYMAZ.'" style="width :160px; background-color: '.BUTTON_ON_OUT.';"
                        onmouseover="this.style.backgroundColor=\''.BUTTON_ON_OVER.'\'; this.style.fontWeight=\'bold\';"
                        onmouseout="this.style.backgroundColor=\''.BUTTON_ON_OUT.'\'; this.style.fontWeight=\'normal\';" 
                    />
                </form>
            ';
            //product form
            $product_form = '
                <table  border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="'.$bgcolor.'">
                    <tr>
                        <td>
                            <b>'.C_NAZOV.':</b> '.$Product_Name.'
                            <br />
                            <b>'.C_KOD.':</b> '.$Product_Code.'
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:10px;">
                            <b>'.C_POPIS.':</b>
                            <br>
                            '.$Product_Descr.'
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:10px;">
                            <b>'.C_DPH.': '.$Product_DPH.'
                            %
                            <b>'.C_CENA.':</b> '.FormatItAsCurrencyTEXTEDIT($Product_Price).'
                            '.C_MENA.' / '.$Product_UnitType.'
                        </td>
                    </tr>
                    <tr>
                        <td style="padding-top:10px;">
                            <input type="checkbox" value="1/" name="action" DISABLED '.$ChBox[0].' />
                            <font color="red" ><small><b>'.C_AKCIA_POPIS.'</b></small></font>
                            <input type="checkbox" value="2/" name="inStack" DISABLED '.$ChBox[1].' />
                            <font color="black" ><small>'.C_TOVAR_NA_SKLADE.'</small></font>
                        </td>
                    </tr>

                </table>
            ';
            //images list
            $image_name  ="../data/images/".$sql_array_Prodct->ID."mini.jpg";
            $image_name2 ="../data/images/".$sql_array_Prodct->ID."d2mini.jpg";
            $image_name3 ="../data/images/".$sql_array_Prodct->ID."d3mini.jpg";
            $images_list = '
                <tr>
                    <td>
                        <center><b>'.C_OBRAZKY.':</b></center>
                    </td>
                </tr>
            ';
            if(file_exists($image_name)) $images_list .= "
                <tr>
                    <td width=\"90px\">
                        <img
                            style=\"cursor:hand;\"
                            src=\"".$image_name."?n=".rand(0, 2000)."\" align=\"left\" vspace=\"0px\" style=\"margin:5px;width : 70px;\"
                            onClick=\"javascript:window.open('image_show.php?image_name_big=../data/images/".$sql_array_Prodct->ID.".jpg','Image','width=680px,height=500px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                        />
                    </td>
                </tr>";

            if(file_exists($image_name2)) $images_list .= "
                <tr>
                    <td width=\"90px\">
                        <img
                            style=\"cursor:hand;\"
                            src=\"".$image_name2."?n=".rand(0, 2000)."\" align=\"left\" vspace=\"0px\" style=\"margin:5px;width : 70px;\"
                            onClick=\"javascript:window.open('image_show.php?image_name_big=../data/images/".$sql_array_Prodct->ID."d2.jpg','Image','width=680px,height=500px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                        />
                    </td>
                </tr>";

            if(file_exists($image_name3)) $images_list .= "
                <tr>
                    <td width=\"90px\">
                        <img
                            style=\"cursor:hand;\"
                            src=\"".$image_name3."?n=".rand(0, 2000)."\" align=\"left\" vspace=\"0px\" style=\"margin:5px;width : 70px;\"
                            onClick=\"javascript:window.open('image_show.php?image_name_big=../data/images/".$sql_array_Prodct->ID."d3.jpg','Image','width=680px,height=500px,location=no,directories=no,menubar=no,resizeable=yes,status=no,toolbar=no,scrollbars=yes');\"
                        />
                    </td>
                </tr>";

            //table
            print '
                <table  border="0" cellpadding="3" cellspacing="3" width="780px" bgcolor="'.$bgcolor.'">
                    <tr>
                        <td style="width:190px; text-align:left; vertical-align:top; border-right: 1px dotted black;"> <!-- Images -->
                            <table  border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="'.$bgcolor.'">
                                '.$images_list.'
                            </table>
                        </td>
                        <td style="width:410px; text-align:left; vertical-align:top; border-right: 1px dotted black;"> <!-- Products info -->
                            '.$product_form.'
                        </td>
                        <td style="width:160px; text-align:right; vertical-align:top;"> <!-- Controls -->
                            <table  border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="'.$bgcolor.'">
                                <tr>
                                    <td>
                                        '.$cancel_button.'
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        '.$edit_button.'
                                    </td>
                                </tr>
                                <tr>
                                    <td style="padding-top:10px;">
                                        '.$delete_button.'
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            ';
        }
        else{
            //zakazany stav
            echo"ERROR SAVING";
        }
   }
}
                   print "</table>";
                   $counter++;
}


        print "<br />";
        PrintLine();

    //**************************************************************************
    //
    //Vytvorenie menu pre vyber zobrazovanej stranky (rozdelenie zobrazovane hotovaru) - ulozene dole
    //
    //**************************************************************************
    //$sql_psel= "SELECT COUNT(*) FROM products WHERE SC_ID=".$Category_ID;
    
    if(trim($_REQUEST['Search_Value'])!=''){
      if(file_exists("modules/tables/insert_11.inc")){
        $sql_psel= "
            SELECT COUNT(*) FROM products,table_value
            WHERE (		
              (products.Product_Name LIKE '%".$Search_Value."%') OR
              (products.Product_Code='".$Search_Value."') OR
              (products.Product_Descr LIKE '%".$Search_Value."%') OR
              (
                (table_value.descr_value LIKE '%".$Search_Value."%') AND
                (products.ID=table_value.ID_product)
              )
            ) GROUP BY (products.ID)
        ";
      }
      else{
        $sql_psel= "
            SELECT COUNT(*) FROM products
            WHERE(
            (Product_Name LIKE '%".$Search_Value."%') OR
            (Product_Code='".$Search_Value."') OR
            (Product_Descr LIKE '%".$Search_Value."%')
            )
            GROUP BY (ID)
        ";
      }
    }    
    else{
      if(trim($Category_ID)!='') $sql_psel= "SELECT COUNT(*) FROM products WHERE SC_ID=".$Category_ID;
    }
        
        
        
        
        
        
    $sql_array_Prodct = mysql_fetch_row(mysql_query($sql_psel));
    do{
      if (($sql_array_Prodct[0]/$ItemsOnPage)<=1) break;
      print"<center><table><tr>";

// Podmienka prvej >>>> --------------------------------------------------------------------
           if(($sql_array_Prodct[0]/$ItemsOnPage>$ShowQvantumPage) and ($ActualQvantumPage-$ShowQvantumPage>=0)){
             print "<td>";
             print "<form  action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
             if($sql_array_Prodct[0]>$ShowQvantumPage)
               print "<input type=\"submit\" value=\"<<<\"  style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
                             onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                             onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
               $xxx=$ActualQvantumPage-$ShowQvantumPage;
               $Pagexxx=$xxx;
               print "<input type=\"hidden\" value=\"".$Pagexxx."\" name=\"PageNo\" />";
               print "<input type=\"hidden\" value=\"".$xxx."\" name=\"ActualQvantumPage\" />";
               print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
               print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
               print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
             print "</form>";
             print "</td>";
             }
 //--------------------------------------------------------------------------------------

//podmienka zvysnych stranok------------------------------------------------------------
          if(($ActualQvantumPage/$ShowQvantumPage)==floor(($sql_array_Prodct[0]/$ItemsOnPage)/$ShowQvantumPage))
              { if($sql_array_Prodct[0]%$ItemsOnPage==0)
                    $ShowActualQvantumPage=((($sql_array_Prodct[0]/$ItemsOnPage)%$ShowQvantumPage));
                else
                    $ShowActualQvantumPage=((($sql_array_Prodct[0]/$ItemsOnPage)%$ShowQvantumPage)+1);
              }
          else
              {$ShowActualQvantumPage=$ShowQvantumPage;}
 //---------------------------------------------------------------------------------------
      for($i=$ActualQvantumPage;$i<$ActualQvantumPage+$ShowActualQvantumPage;$i++)
    {
      print "<form  action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
          print "<td>";
          $Xi=$i+1;
          if($PageNo==$i)
            print "<input type=\"submit\" value=\"".$Xi."\" name=\"PageNo\"  style=\"width :50px; background-color: ".BUTTON_ON_OVER.";\">";
          else
            print "<input type=\"submit\" value=\"".$Xi."\" name=\"PageNo\" style=\"width :25px; background-color: ".BUTTON_ON_OUT.";\"
                            onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                            onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
          print "<input type=\"hidden\" value=\"1\" NAME=\"PageQuanter\">";
          print "<input type=\"hidden\" value=\"".$ActualQvantumPage."\" NAME=\"ActualQvantumPage\">";
          print "<input type=\"hidden\" value=\"".$Path."\" NAME=\"path\">";
          print "<input type=\"hidden\" value=\"".$Category_ID."\" NAME=\"ID\">";
          print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
          print "</form>";
          print "</td>";
    }

 //podmienka doprednej >>>> -----------------------------------------------------------
if(($sql_array_Prodct[0]/$ItemsOnPage) > ($ActualQvantumPage+$ShowQvantumPage)){
      print "<td>";
      print "<form  action=\"adm_contents.php\" target=\"contents\" method=\"post\">";
      print "<input type=\"submit\" value=\">>>\"  style=\"width :50px; background-color: ".BUTTON_ON_OUT.";\"
                             onmouseover=\"this.style.backgroundColor='".BUTTON_ON_OVER."'; this.style.fontWeight='bold';\";
                             onmouseout=\"this.style.backgroundColor='".BUTTON_ON_OUT."'; this.style.fontWeight='normal';\" />";
      $xxx=$ActualQvantumPage+$ShowQvantumPage;
      $Pagexxx=$xxx;
      print "<input type=\"hidden\" value=\"".$Pagexxx."\" name=\"PageNo\" />";
      print "<input type=\"hidden\" value=\"".$xxx."\" name=\"ActualQvantumPage\" />";
      print "<input type=\"hidden\" value=\"".$Path."\" name=\"path\" />";
      print "<input type=\"hidden\" value=\"".$Category_ID."\" name=\"ID\" />";
      print "<input type=\"hidden\" value=\"".$Search_Value."\" name=\"Search_Value\" />";
    print "</form>";
    print "</td>";
    }
 //--------------------------------------------------------------------------------------
    print "</tr></table></center>";
    PrintLine();
    }while(false);




        mysql_close();
}
while(false)
?>


</body>
</html>